home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0005_How to match file date-time stamps.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-22  |  840 b   |  23 lines

  1.  
  2. Q: "How can I write a function that sets the date of one file equal to the
  3.    date of another file?"
  4.  
  5. A: No problem.  Just use the following function, which takes two strings
  6.    representing full DOS path/file names.  The file who's date you
  7.    wish to set is the second parameter, and the date you wish to set it to
  8.    is given by the file in the first parameter.
  9.  
  10. procedure CopyFileDate(const Source, Dest: String);
  11. var
  12.   SourceHand, DestHand: word;
  13. begin
  14.   SourceHand := FileOpen(Source, fmOutput);       { open source file }
  15.  
  16.   DestHand := FileOpen(Dest, fmInput);            { open dest file }
  17.   FileSetDate(DestHand, FileGetDate(SourceHand)); { get/set date }
  18.   FileClose(SourceHand);                          { close source file } 
  19.   FileClose(DestHand);                            { close dest file }
  20. end;
  21.  
  22.  
  23.